GBML manual / Lists

list_min

Gives back the smallest number target holds: list_min(scores) of 7, 3 and 9 is 3. Use it for the lowest cooldown or the shortest distance.

Syntax

list_min(target) -> element

Arguments

NameType
targetlist

Returns

element

Description

Gives back the smallest number in target, a list. list_min(scores) of 7, 3 and 9 is 3. Use it for the lowest cooldown or the shortest distance.

Example

/// @type {list<int>}
var scores = [7, 3, 9];
var answer = list_min(scores);   // 3

The small print

Cost

One pass over the items.

On the GBA

One pass from the first item to the last, keeping the smallest seen so far - nothing is changed or copied. For a list of list_length(target) items it takes that many comparisons. Whole numbers and decimals only; text, yes-or-no values, structs and references are refused when the project is checked. An empty one gives back 0.

See also: list_maxlist_sumlist_sort_byarray_minlist_lengthListsData containers